#include <iostream>
#include <initializer_list>
using namespace std;



struct _Iter_less_iter
{
    /* data */
    template <typename _Iterator1, typename _Iterator2>
    bool operator() (_Iterator1 first, _Iterator2 sencond) const{
        std::cout << "operator" << std::endl;
        return *first < *sencond;
    }
};


inline _Iter_less_iter _iter_less_iter()
{
    std::cout << "_iter_less_iter" << std::endl;
    return _Iter_less_iter();
}

template <typename _F, typename _C>
_F __max_element(_F _first, _F _last, _C _comp) {
        std::cout << "__max_element begin" << std::endl;
    if(_first == _last)
        return _first;
    _F _res = _first;
    while(++ _first != _last) {
        if(_comp(_res, _first)) {
            _res = _first;
        }
    }
    std::cout << "__max_element end" << std::endl;
    return _res;
}


template<typename _Type> 
inline _Type max_element1(_Type _first, _Type _last) 
{
    std::cout << "max_element1" << std::endl;
    return __max_element(_first, _last, _iter_less_iter());
}

template<typename _Type>
inline _Type max(initializer_list<_Type> _l) {
    cout<<"max"<<endl;
    return *max_element1(_l.begin(), _l.end());
}


int main(int argc, const char *argv[])
{
    std::cout << max<double>({2, 3, 4, 5, 1, 12.4, 3, 6, 32, 6.7}) << std::endl;
    return 0;
}